Option Strict On

Public Class COven
    
  ' ========== Stae =================
  Private Const DOOROPEN As Integer = 1    ' Drzwiczki piekarnika zamknite
  Private Const DOORCLOSED As Integer = 0  ' Drzwiczki piekarnika otwarte
  Private Const OVENON As Integer = 1      ' Piekarnik wczony
  Private Const OVENOFF As Integer = 0     ' Piekarnik wyczony
  Private Const LIGHTON As Integer = 1     ' wiato w piekarniku wczone
  Private Const LIGHTOFF As Integer = 0    ' wiato w piekarniku wyczone
  Private Const BROILTEMP As Integer = 550 ' Temperatura rusztu
  Private Const CLEANTEMP As Integer = 600 ' Temperatura samooczyszczania 

  ' ========== Dane skadowe klasy ==========
  Private mOvenStatus As Integer ' Czy piekarnik jest wczony, czy nie
  Private mTemperature As Integer  ' Temperatura pieca
  Private mDoorStatus As Integer   ' Czy drzwiczki s otwarte, czy zamknite 
  Private mOvenLight As Integer    ' Czy wiato jest wczone, czy wyczone  


  ' ========== Konstruktor ================
  Public Sub New()
    ' Cel: nada zmiennym ich waciwe wartoci.
    ' Jeli nawet niektre s zerowe, ustawiamy je w wyrany sposb.
    mOvenStatus = OVENOFF     ' Piekarnik wyczony 
    mTemperature = 0          ' Piekarnik nie jest nagrzany
    mDoorStatus = DOORCLOSED  ' Drzwiczki piekarnika s zamknite
    mOvenLight = LIGHTOFF     ' wiato w piekarniku jest wyczone 

  End Sub

  ' ================ Waciwoci ===========
  Public Property OvenStatus() As Integer
    ' Cel: uzyska biecy stan piekarnika.
    '      0 = piekarnik wyczony, 1 = piekarnik wczony
    Get
      Return mOvenStatus
    End Get

    ' Cel: zmieni stan piekarnika. Zakadamy, e  
    '      Value jest dan temperatur.
    '      Value = 0 oznacza, e piekarnik jest 
    '      wyczony. Kada inna warto wskazuje 
    '      podan warto temperatury
    Set(ByVal Value As Integer) ' Wyczamy lub wczamy piekarnik
      Dim Flag As Integer

      If Value <> OVENOFF Then
        mOvenStatus = OVENON  ' Piekarnik jest teraz wczony
      Else
        mOvenStatus = OVENOFF ' Piekarnik jest teraz wyczony
      End If
      Flag = Bake(Value)

    End Set
  End Property

  Public Property DoorStatus() As Integer
    ' Cel: ta waciwo podaje stan drzwi
    Get
      Return mDoorStatus
    End Get

    ' Cel: ta waciwo ustawia stan drzwi
    Set(ByVal Value As Integer)
      If Value = 0 Then
        mDoorStatus = DOORCLOSED
      Else
        mDoorStatus = DOOROPEN
      End If
    End Set
  End Property

  Public Property LightStatus() As Integer
    ' Cel: ta waciwo podaje stan wiata
    Get
      Return mOvenLight
    End Get

    ' Cel: ta waciwo ustawia stan wiata
    Set(ByVal Value As Integer)
      If Value = 0 Then
        mOvenLight = LIGHTOFF
      Else
        mOvenLight = LIGHTON
      End If

    End Set
  End Property

  Public Property Temperature() As Integer
    ' Cel: ta waciwo podaje temperatur
    Get
      Return mTemperature
    End Get

    ' Cel: ta waciwo zmienia temperatur
    Set(ByVal Value As Integer)
      Dim Flag As Integer

      If Value < 0 Then
        mTemperature = 0
      End If
      Flag = Bake(Value)   ' Ustaw temperatur piekarnika
    End Set
  End Property

  ' ================ Metody ==============

  Public Function Bake(ByVal Temp As Integer) As Integer
    ' Cel: ta metoda jest uywana do ustawiania temperatury piekarnika 
    '      do temperatury podanej w tej metodzie.
    '
    ' Lista argumentw:
    '  Temp   podana temperatura 
    '
    ' Zwracana warto:
    '  integer  1 jeli wszystko jest w porzdku, 0 w przypadku bdu
    '
    If mOvenStatus = OVENOFF Then  ' Piekarnik jest teraz wyczony 
      Return 0           ' Bd
    End If

    mTemperature = Temp    ' Piekarnik jest wczony, ustaw temperatur
    Return 1               ' Wszystko jest w porzdku

  End Function

  Public Function Preheat(ByVal Temp As Integer) As Integer
    ' Cel: ta metoda jest uywana do wstpnego podgrzania piekarnika
    '      do temperatury o podanej wartoci.
    '
    ' Lista argumentw:
    '  temp   podana temperatura 
    '
    ' Zwracana warto:
    '  integer  1, jeli wszystko jest w porzdku, 0 w przypadku bdu 
    '
    Return Bake(Temp)

  End Function

  Public Sub Broil()
    ' Cel: ta metoda suy do wczania rusztu 
    '      w piekarniku.
    '
    ' Argumenty:
    ' Niedostpne
    '
    ' Zwracana warto:
    ' Niedostpna 
    '
    mTemperature = BROILTEMP

  End Sub

  Public Sub SelfClean()
    ' Cel: ta metoda jest stosowana do samooczyszczania piekarnika. 
    '
    ' Argumenty:
    ' Niedostpne
    '
    ' Zwracana warto:
    ' Niedostpna
    '
    mTemperature = CLEANTEMP

  End Sub

End Class
